The actor model is a mathematical model of concurrent computation that treats “actors” as the universal primitives of concurrent computation. An actor is a type of object (in the sense of object-orientated programming): it is a data structure comprising data and one or more functions for operating on that data. Actors may modify their own private state, but can only affect each other through messages between them. In response to a message that it receives, an actor can: make local decisions, create more actors, send more messages, and determine how to respond to the next received message. These tasks could be carried out in parallel. Recipients of messages are identified by an address, sometimes called a “mailing address”. Thus an actor can only communicate with actors whose addresses it has. It can obtain those from a message it receives, or if the address is for an actor it has itself created. For example, electronic mail (e-mail) can be modelled as an actor system, with email accounts being modelled as actors and email addresses as actor addresses.
What characterises an actor over simply any object of an object-orientated programming is that an actor is run on only one thread at any given time.
Threads are portions of code which can, at least for a time, be run independently of one another, and which can be run concurrently or in parallel with one another. Concurrency refers to the case where threads are interleaved with one another through the same execution unit of a processor, thus providing an effectively simultaneous form of execution. Parallelism refers to the case where threads are executed truly simultaneously through different parallel execution units. In a given program or set of programs, two or more threads of the program may be run concurrently and/or in parallel at any one time, depending on the resources of the system.
Threads can take the form of hardware threads or software threads. In the case of hardware threads, the processor itself comprises hardware support for each thread, at least in the form a set of context registers for each of the threads that can be run concurrently or in parallel at any one time. Each set of context registers stores a program state of a respective thread, such as the program counter and operands. In the case of software threads, the concurrency or parallelism is achieved not (or not only) though hardware support for each thread, but rather the thread states are maintained at a higher level in software. Either way, in many cases the threads may be scheduled for execution by the operating system running on the computer system. The threads in question may comprise threads of the operating system itself or threads of one or more applications run on the operating system.